<?php
/**
 * Created by PhpStorm.
 * User: meng
 * Date: 2023/9/5
 * Time: 15:09
 */

use app\admin\controller\Auth;
use app\admin\controller\Menu;
use app\admin\controller\Permissions;
use app\admin\controller\Settings;
use app\admin\controller\User;
use app\admin\controller\File;
use Webman\Route;

Route::group('/admin', function () {
    // 菜单
    Route::group('/menu', function () {
        Route::get('', [Menu::class, 'index']);
        Route::get('/{id}', [Menu::class, 'get']);
        Route::post('', [Menu::class, 'create']);
        Route::put('/{id}', [Menu::class, 'update']);
        Route::delete('/{id}', [Menu::class, 'delete']);
    });
    // 管理员
    Route::group('/user', function () {
        Route::get('', [User::class, 'index']);
        Route::get('/{id}', [User::class, 'read']);
        Route::post('', [User::class, 'create']);
        Route::put('/{id}', [User::class, 'update']);
        Route::delete('/{id}', [User::class, 'delete']);
    });
    // 权限
    Route::group('/permission', function () {
        Route::get('', [Permissions::class, 'index']);
        Route::get('/{id}', [Permissions::class, 'read']);
        Route::put('/{id}', [Permissions::class, 'update']);
        Route::delete('/{id}', [Permissions::class, 'delete']);
        Route::post('', [Permissions::class, 'create']);
    });
    // 配置
    Route::group('/settings', function () {
        Route::get('', [Settings::class, 'index']);
        Route::post('', [Settings::class, 'create']);
        Route::delete('/{id}', [Settings::class, 'delete']);
        Route::put('/{id}', [Settings::class, 'update']);
        Route::get('/{id}/item', [Settings::class, 'settingItemList']);
        Route::post('/{id}/item', [Settings::class, 'createSettingItem']);
        Route::put('/{id}/item/{itemId}', [Settings::class, 'updateSettingItem']);
        Route::delete('/{id}/item/{itemId}', [Settings::class, 'deleteSettingItem']);
        Route::post('/save', [Settings::class, 'saveSettingValue']);
    });
    // 文件
    Route::group('/file', function () {
        Route::post('/upload/single', [File::class, 'uploadSingle']);
        Route::post('/upload/multiple', [File::class, 'uploadMultiple']);
    });
    // 获取用户信息
    Route::get('/userinfo', [Auth::class, 'userinfo']);
    // 图片验证码
    Route::get('/captcha', [Auth::class, 'captcha']);
    // 登录
    Route::post('/login', [Auth::class, 'login']);
    // 刷新token
    Route::post('/refresh_token', [Auth::class, 'refreshToken']);
});
